<%@page import="com.metacube.metaconnect.Service.UserInformationService"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<link rel="Stylesheet" href="css/home.css" type="text/css">
<script type="text/javascript" src="js/UserProfile.js">
	</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<%
if(session.getAttribute("emailId")==null)
	response.sendRedirect("index.jsp");
else
{
	%>
	<%
		ArrayList userInfo = new UserInformationService().getuserInfo(session.getAttribute("emailId").toString());
	%>
	
	<title>
	
	<%
		if(request.getAttribute("userDetails")!=null)
		{
			request.setAttribute("userDetails", request.getAttribute("userDetails"));
		}
	%>
	<%
	if(userInfo.get(0)!=null)
	%>
	<%=userInfo.get(0).toString() %>
	</title>
	 
	</head>
  <body>
	<%
	String path="";
	String UserName="";
	%>
	<% 
		if(userInfo.get(0)!=null){	
	%>
	<% UserName=userInfo.get(0).toString();
	%>
	<%} %>
		<div id=wrapper>
		<jsp:include page="HomeHeader.jsp">
			<jsp:param value="<%=UserName %>" name="UserName"/>
		</jsp:include>
		<div id=main-container>
		<div id="left-container">
			<%if(userInfo.size()==5){ %>
			<table cellpadding="5" cellspacing="5">
				<tr>
					<td>
							<% 
								if(userInfo.get(4)!=null)
								{	
									path="Upload/"+userInfo.get(4).toString();
								}
								else if(userInfo.get(1).toString().equals("Male")){ 
									path="Upload/male.jpg";
								}
								else 
								{
										path="Upload/female.jpg";
								}
							%>
								<img class=photo alt="hello" src="<%=path %>"  >
					</td>
				</tr>
				<tr>
					<td>
						<% 
							String tempEmail  = session.getAttribute("emailId").toString();
							String temp= "home.jsp?tempEmail="+tempEmail+","+path;
						%> 
						<html:link styleClass="link" href="<%=temp %>" >Change Picture</html:link>
					</td>
				</tr>
				<tr>
					<td>
						<% 
								if(request.getAttribute("errorInUpdatePic")!=null){
							%>
								<font color="red" size="+1"><%=request.getAttribute("errorInUpdatePic").toString() %></font>
							<%
								}
							%>
					</td>
				</tr>
				<tr>
					<td>
						<hr/>
						<font size="+2" >
						<% 
							if(userInfo.get(0)!=null){	
						%>
						<%=userInfo.get(0).toString() %>
						<%} %>
						</font>
					</td>
				</tr>
				<tr>
					<td>
						<span class="Info">Project:</span>
						<span class=userInfo > <% 
								if(userInfo.get(2)!=null){	
							%>
							<%=userInfo.get(2).toString() %>
							<%} %> </span>
					</td>
				</tr>
				<tr>
					<td>
						<span class="Info"> Designation: </span>
						<span class=userInfo ><% 
								if(userInfo.get(3)!=null){	
							%>
							<%=userInfo.get(3).toString() %>
							<%} %></span>
					</td>
				</tr>
				<tr>
					<td>
						<hr/>
						<html:link styleClass="link" action="UpdateProfileController">Update Your Profile</html:link>
					</td>
				</tr>
				<tr>
					<td>
						<hr/>
							<% 
								if(request.getAttribute("errorInUpdate")!=null){
							%>
								<font color="red" size="+1"><%=request.getAttribute("errorInUpdate").toString() %></font>
							<%
								}
							%>
					</td>
				</tr>
			</table>
					<%} %>
		</div>
		<div id="middle-container" >
			<div id="statusHeader">
				<form action="postStatusServlet" method="post">
					<table>
						<tr>
							<td colspan="2"> <span id=postboxheader > Post Your Status :- </span></td>
						</tr>
						<tr>
						<td id="post_table">
									<textarea style="word-wrap:break-word;" rows="4" cols="50" onKeyPress="return imposeMaxLength(this,299)" name="postArea" id="postArea" onfocus='focusPostArea(this)' onblur='blurPostArea(this)' >What You Are Working on????....</textarea>
									<div id="post_td" ><font color="gray" size="-1">max 300 characters.........</font> <input type="submit" value="Share" class="button" onclick="isEmpty()"/>
									</div>
						</td>
						</tr>
					</table>
				</form>
				<hr/>
			</div>
			<%request.setAttribute("path",path); %>
	
			<div id="posts">
					<%if(request.getAttribute("userDetails")==null && request.getAttribute("users")==null && request.getParameter("tempEmail")==null) {%>
		
					<jsp:include page="Posts.jsp"></jsp:include>
			
					<%}
					
					else if(request.getAttribute("users")!=null){
						@SuppressWarnings("unchecked")
						ArrayList<String> users = (ArrayList<String>)request.getAttribute("users");
						System.out.print("home1334");
						request.setAttribute("users", users);
					%>
						<jsp:include page="Search.jsp"></jsp:include>
					<%}else if(request.getParameter("tempEmail")!=null){
						String temail=request.getParameter("tempEmail");
					%>
					<jsp:include page="UpdateProfilePicture.jsp?tempEmail=<%=temail %>"></jsp:include><%} else{%>
					<script type="text/javascript">
				    document.getElementById('statusHeader').style.display='none';
					</script>
					<jsp:include page="editprofile.jsp"></jsp:include><%} %>
				
			</div>
		</div>
		<div id="right-container">
<jsp:include page="events.jsp"></jsp:include>
			</div>
		</div>
		<jsp:include page="Footer.html"></jsp:include>
		
		</div>
<%} %>
</body>
</html>